package logic

import (
	"context"
	"newuser/modles/mysql"

	"newuser/userrpc/internal/svc"
	"newuser/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodListLogic {
	return &GoodListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品查询
func (l *GoodListLogic) GoodList(in *userrpc.GoodListRequest) (*userrpc.GoodListResponse, error) {
	// todo: add your logic here and delete this line

	var good mysql.Goods
	err, list := good.GoodsFind(mysql.DB, in)
	if err != nil {
		return nil, err
	}

	return &userrpc.GoodListResponse{
		List: list,
	}, nil
}
